﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TA.Turbo
{
	/// <summary>
	/// Markup template which consists of two other markup templates.
	/// </summary>
	/// <remarks>
	/// Useful when two templates need to be separated on the server but combined on the client.
	/// </remarks>
	public class CombinedTemplate : BaseMarkupTemplate
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="first"></param>
		/// <param name="second"></param>
		public CombinedTemplate(string name, IMarkupTemplate first, IMarkupTemplate second)
			: base(name)
		{
			this._first = first;
			this._second = second;
		}
		#endregion
		#region PROPS
		///// <summary>
		///// Gets the default control ID prefix (ie., "dataControl$Item" where "Item" is the name of the template).
		///// </summary>
		//public override string IdPrefix
		//{
		//  get
		//  {
		//    return this._first.IdPrefix;
		//  }
		//}
		#endregion
		#region METHODS
		#endregion
		#endregion
		#region INTERNAL
		#region VARS
		IMarkupTemplate _first, _second;
		#endregion
		#region METHODS
		/// <summary>
		/// Prepares the HTML markup and the initialization script for this template.
		/// </summary>
		protected override void PrepareMarkupAndScript()
		{
			this.SetMarkup(this._first.Markup + this._second.Markup);
			this.SetScript(this._first.Script + this._second.Script);
		}
		/// <summary>
		/// SerializeContents
		/// </summary>
		/// <param name="jw"></param>
		public override void SerializeContents(TA.JSON.JsonWriter jw)
		{
			base.SerializeContents(jw);

			//jw.PropertyName("I");
			//jw.Value(this.IdPrefix);
		}
		#endregion
		#endregion
	}
}
